package UDP_test;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class SendMassage {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket();
        Scanner s = new Scanner(System.in);
        while (true) {
            System.out.println("请输入要发送的内容");
            String str = s.nextLine();
            if ("886".equals(str)) {
                break;
            }
            byte[] b=str.getBytes();
            InetAddress address=InetAddress.getByName("127.0.0.1");
            DatagramPacket packet = new DatagramPacket(b, b.length, address, 10086);
            socket.send(packet);
        }
        socket.close();
        System.out.println("发送成功");
    }
}
